public class Dog {

    //属性
    public String name;//默认为null
    public String category;
    public int age;//默认为0


    //方法
    public void eat(String food){
        //方法中可以使用前面创建的成员变量的属性
        System.out.println(name + "正在吃" + food);
    }
    public void bark(){
        System.out.println("汪汪汪");
    }
    public void sleep(){
        System.out.println("正在睡觉");
    }



    //类的使用
    public static void main(String[] args) {
        Dog dog = new Dog();//创建dog变量
        //new Dog
        dog.age = 10;
        System.out.println(dog.age);
        dog.name = "大黄";
        System.out.println(dog.name);
        dog.bark();
        dog.eat("狗粮");

        Dog dog1 = new Dog();
        dog1.name = "旺财";
        dog1.eat("肉");
    }
}
